-- Tunnel from Glade to Tower 

function autoexec()

if (get_numchrs() == 2) or (get_progress(P_UNIFORM > 0)) or (get_progress(P_QUEST1 == 11)) then
  set_ent_active(0, 0);


end

return
refresh()
end


function postexec()
  
return
end


function zone_handler(zn)
  if (zn == 0) then
    combat(9)

  elseif (zn == 1) then
    change_map("glade","tunnel_exit");

  elseif (zn == 2) then
    warp("2dn",8)

  elseif (zn == 3) then
    warp("3up",8)
 
  elseif (zn == 4) then
    warp("4up",8)
 
  elseif (zn == 5) then
    warp("5dn",8)

  elseif (zn == 6) then
    warp("6dn",8)

  elseif (zn == 7) then
    warp("7up",8)

  elseif (zn == 8) then
    warp("8up",8)

  elseif (zn == 9) then
    warp("9dn",8)

  elseif (zn == 10) then
    warp("10dn",8)

 elseif (zn == 11) then
    warp("11up",8)

 elseif (zn == 12) then
    warp("12up",8)

 elseif (zn == 13) then
    warp("13dn",8)

 elseif (zn == 14) then 
  if (get_progress(P_UNIFORM) == 1) then
    thought(HERO1, "I better put on this unifrom before I go out there.");
    set_ent_chrx(HERO1, 15);
    set_progress(P_UNIFORM,2);
  else
    change_map("towerx","tunnel2_exit");
 end

 elseif (zn == 15) then
    set_save(1)

 elseif (zn == 16) then
    set_save(0)

 elseif (zn == 17) then
   bubble(HERO1,"All right lets see if this key works.");
   set_progress(P_QUEST1, 10);
   refresh();
   sfx(25);
   

  elseif (zn == 18) then  
    if (get_progress(P_UNIFORM) == 0) then
      bubble(HERO1, "Here's an old uniform, I think it will fool them.");
      set_ent_chrx(HERO1, 15);
      set_progress(P_UNIFORM,2);
    else
      bubble(HERO1, "Theres nothing else left.");
     end
 
  elseif (zn == 19) then
  if (get_progress(P_UNIFORM) == 2) then
    thought(HERO1,"I think I'm going to change out of this uniform before I go back.");
    set_ent_chrx(HERO1, 0);
    set_progress(P_UNIFORM,1);
  end
  
 elseif (zn == 20) then
    if (get_numchrs() == 2) then
      bubble(HERO2,"I can go no farther. I must return to the Order.");
      remove_chr(get_pidx(1))
      set_ent_active(HERO2, 0)    
      set_ent_id(0, SENSAR)
      set_ent_active(0, 1);
      set_ent_script(0, "L1D2L1R1")
      set_ent_facing(0, FACE_RIGHT)
      set_ent_facing(HERO1, FACE_LEFT)
      wait_for_entity(0, HERO1)
      bubble(0,"Good luck, Corin.");
      bubble(HERO1,"Thanks, this quest is not going to be easy.");
 
   end
        end

function entity_handler(en)
  if (en == 0) then
    if (party[0] == Sensar) then
      bubble(en, "I'm ready to go save King Amalric.")
    else 
      bubble(en, "Good luck $0, I hope to see you soon in good health and good company.")
  end
  
end
  end

     end


function refresh()
  if (get_progress(P_QUEST1) > 9) then
    set_obs("tower_door",0)
    set_zone("tower_door", 254)
    set_btile("tower_door", 96)
  end

  return
end


